// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   IIImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.II;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;
import com.sunwayhorizo.health.hl7.datatypes.UID;

// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            ANYImpl, BLImpl, CSImpl, NullFlavorImpl, 
//            STImpl, TYPEImpl, UIDImpl

public class IIImpl extends ANYImpl implements II
{

    public static final String RCS_ID = "$Header: IIImpl.java 115.32 2005/09/16 09:23:32 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion(
        "$Header: IIImpl.java 115.32 2005/09/16 09:23:32 amchanda noship $", "oracle.apps.ctb.hl7.types.common");
    protected ST _extension;
    protected UID _root;
    protected ST _identifierName;
    protected ST _clinicNo;
    protected CE _iiType;
    protected ST _iiSouce;
    protected ST _iiState;

    private static final II nullNI = new IIImpl(CSImpl.valueOf("NI"));
    private static final II nullOTH = new IIImpl(CSImpl.valueOf("OTH"));
    private static final II nullNINF = new IIImpl(CSImpl.valueOf("NINF"));
    private static final II nullPINF = new IIImpl(CSImpl.valueOf("PINF"));
    private static final II nullUNK = new IIImpl(CSImpl.valueOf("UNK"));
    private static final II nullASKU = new IIImpl(CSImpl.valueOf("ASKU"));
    private static final II nullNAV = new IIImpl(CSImpl.valueOf("NAV"));
    private static final II nullMSK = new IIImpl(CSImpl.valueOf("MSK"));
    private static final II nullNA = new IIImpl(CSImpl.valueOf("NA"));
    private static final II nullNASK = new IIImpl(CSImpl.valueOf("NASK"));


    public static II valueOf(UID uid, ST extension, ST identifierName, CE iiType, ST iiSouce, ST iiState)
    {
        return new IIImpl(uid, extension,identifierName, iiType, iiSouce, iiState);
    }


    public static II valueOf(UID uid, ST st, ST st1)
    {
        return new IIImpl(uid, st, st1);
    }


    public static II valueOf(UID root, ST extension, ST identifierName, ST state)
    {
        return new IIImpl(root, extension, state, identifierName);
    }


    public static II valueOf(UID root, ST extension, ST identifierName, ST state, ST _clinicNo)
    {
        return new IIImpl(root, extension, state, identifierName, _clinicNo);
    }


    protected IIImpl(UID uid, ST st, ST st1)
    {
        if (uid.isNull().isTrue())
        {
            throw ANYImpl.newNullException("II", "constructor", "root");
        }
        else
        {
            _root = uid;
            _extension = st;
            _iiState = st1;
            return;
        }
    }


    protected IIImpl(UID root, ST extension, ST state, ST identifierName)
    {
        if (root.isNull().isTrue())
        {
            throw ANYImpl.newNullException("II", "constructor", "root");
        }
        else
        {
            _root = root;
            _extension = extension;
            _iiState = state;
            _identifierName = identifierName;
            return;
        }
    }


    protected IIImpl(UID root, ST extension, ST state, ST identifierName, ST clinicNo)
    {
        if (root.isNull().isTrue())
        {
            throw ANYImpl.newNullException("II", "constructor", "root");
        }
        else
        {
            _root = root;
            _extension = extension;
            _iiState = state;
            _identifierName = identifierName;
            _clinicNo = clinicNo;
            return;
        }
    }


    protected IIImpl(UID uid, ST extension, ST identifierName, CE iiType, ST iiSouce, ST iiState)
    {
        if (uid.isNull().isTrue())
        {
            throw ANYImpl.newNullException("II", "constructor", "root");
        }
        else
        {
            _root = uid;
            _extension = extension;
            _identifierName = identifierName;
            _iiType = iiType;
            _iiSouce = iiSouce;
            _iiState = iiState;
            return;
        }
    }


    protected IIImpl(UID uid, ST st)
    {
        this(uid, st, null);
    }


    protected IIImpl(CS cs)
    {
        super(true, cs);
        _root = null;
        _extension = null;
        _iiState = null;
        _iiSouce = null;
    }


    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.II;
    }


    public BL equal(ANY any)
    {
        if (!(any instanceof II))
            return BLImpl.FALSE;
        if (isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        }
        else
        {
            II ii = (II) any;
            BL bl = root().equal(ii.root());
            bl = extension().isNull().isFalse() ? bl.and(extension().equal(ii.extension())) : bl.and(ii.extension().isNull());
            return bl;
        }
    }


    public ST extension()
    {
        return _extension;
    }


    public ST identifierName()
    {
        return _identifierName;
    }


    public ST clinicNo()
    {
        return _clinicNo;
    }


    public UID root()
    {
        return _root;
    }


    public CE iiType()
    {
        return _iiType;
    }


    public ST iiSouce()
    {
        return _iiSouce;
    }


    public ST iiState()
    {
        return _iiState;
    }


    public int hashCode()
    {
        int i = 17;
        if (isNull().isFalse())
        {
            // i = 37 * i + root().hashCode();
            // i = 37 * i + (extension().isNull().isTrue() ? 0 :
            // extension().hashCode());
        }
        return i;
    }


    public String toString()
    {
        String s = null;
        if (isNull().isFalse())
        {
            s = _root.stringValue();
            if (_extension != null && _extension.isNull().isFalse())
                s = s + "-" + _extension.stringValue();
        }
        else
        {
            s = "<Null:" + nullFlavor().toString() + ">";
        }
        return s;
    }


    public static II nullII(CS cs)
    {
        String s = null;
        if (cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if (s.equals("NI"))
            return nullNI;
        if (s.equals("OTH"))
            return nullOTH;
        if (s.equals("NINF"))
            return nullNINF;
        if (s.equals("PINF"))
            return nullPINF;
        if (s.equals("UNK"))
            return nullUNK;
        if (s.equals("ASKU"))
            return nullASKU;
        if (s.equals("NAV"))
            return nullNAV;
        if (s.equals("MSK"))
            return nullMSK;
        if (s.equals("NA"))
            return nullNA;
        if (s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }



}
